<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<script th:src="@{/service/js/jtqy.js}"></script>
<title>预签约</title>
<style type="text/css">
body{
	padding: 0px 0px;
}
.laydate-icon{
	line-height: 28px;
    height: 28px;
    border: 1px solid #B6B6B6;
    border-radius: 5px;
	width:84% !important;
}
.spanBtn{
	font-weight: bold;
	color: blue;
	cursor:pointer;
}

.td-content {
	width: 150px;
}
.tabs-wrap>.tabs>li>a{
	border-left:1px solid #438EB9!important;
	border-right:1px solid #438EB9!important;
	border-top:1px solid #438EB9!important;
}
</style>
</head>
<script th:inline="javascript">
    var tdxxArr = [[${tdxxArr}]];
</script>
<script type="text/javascript">
	$(function() {
        $(this).getZydmCache();
	 	initView();
        initData();
	});

	function initData(){
        //激活选定的tab
        var tabIndex = $.QuickUrlUtils.getRequest("tabIndex");
        if(!StringUtils.isEmpty(tabIndex)){
            $('#tabs').tabs('select',parseInt(tabIndex));
		}
	}

	/** 查询  */
	function queryForm(tableId) {
		$("#"+ tableId).datagrid();
	}

	function initView(){
        //查询条件初始化-团队
        $(".YLTDID").createOptions(tdxxArr,{textField : "TDMC" , valueField : "TDID"});

        $('#tabs').tabs({
            border: true,
            fit: true,
            tabWidth: "150",
            onSelect: function(title,index){
                var nowSelectTab = $(this).tabs('getTab',index); //获取到当前激活的tab
                var tableId = nowSelectTab.find("table").eq(1).attr("id");
                if(!StringUtils.isEmpty(tableId)){
                    initTableMethod[tableId](); //初始化table
                }
            }
        })
	}

    /** 团队为空时，查询所有团队  */
    function formatTdid(params,field){
        if(StringUtils.isEmpty(params[field])){
            var tdidArr = [];
            $(".YLTDID:eq(0) option").each(function(){
                var value = $(this).val();
                if(!StringUtils.isEmpty(value)){
                    tdidArr.push(value);
                }
            })
            params[field] = tdidArr.join(',');
        }
    }
	
	/** 审核预签约-跳转到预签约详细页面  */
	function checkYqy(row){
		row.TDMC = row.QYTDMC

		var tabIndex = getTabIndex();
		StoreCache.setCache("BACKINFO", contextRoot + "/jtqy/indexYqy.html?tabIndex=" + tabIndex);
		StoreCache.setCache("JTQYXQINFO", row);
		location = "detail.html?to=yqyDetail&JMXXID=" + row.JMXXID + "&tabIndex=" + tabIndex;
	}

	/** 获取当前激活的tab的下标 */
	function getTabIndex(){
        return $('#tabs').tabs('getTabIndex',$('#tabs').tabs('getSelected'));;
    }

	var initTableMethod = {
	    /* 未审核 */
	    wshYqyTb : function(){
            $("#wshYqyTb").datagrid({
                striped : true,
                fit: true,
                fitColumns: true,
                columns : [[
                    {field : "XM",title : "姓名",width:30,align:'center'},
                    {field : "ZJLXMC",title : "证件类型",width:25,align:'center'},
                    {field : "ZJHM",title : "证件号码",width:45,align:'center',formatter:function(value){
                        if(!StringUtils.isEmpty(value)){
                            return value.replace(/.{8}$/,'********');
                        }
                    }},
                    {field : "SJHM",title : "手机号码",width:35,align:'center'},
                    {field : "JTZZ",title : "家庭住址",width:70,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "QYSJ",title : "预签约时间",width:28,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "RQFLMC",title : "人群分类",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "TDMC",title : "签约团队",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "FWBMC",title : "签约服务包",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "cz",title : "操作",width:40,align:'center', formatter:function(value,row,index){
                        row = JSON.stringify(row).replace(/"/g, '&quot;');
                        return '<span class="spanBtn" onclick="checkYqy(' + row + ')">审核</span>';
                    }}
                ]],
                pagination : true,
                url: contextRoot+"jtqy/queryPage.service",
                onBeforeLoad: function(params){
                    params.QYLX = "00";
                    getContainerDataByClassName('wshConditionBox','condition',params);//查询条件
                    formatTdid(params,"YLTDID");
                    if(StringUtils.isEmpty(params.YLTDID)) return false;
                }
            });
		},

		/* 已审核 */
        yshYqyTb : function(){
            $("#yshYqyTb").datagrid({
                striped : true,
                fit: true,
                fitColumns: true,
                columns : [[
                    {field : "XM",title : "姓名",width:30,align:'center'},
                    {field : "ZJLXMC",title : "证件类型",width:25,align:'center'},
                    {field : "ZJHM",title : "证件号码",width:45,align:'center',formatter:function(value){
                        if(!StringUtils.isEmpty(value)){
                            return value.replace(/.{8}$/,'********');
                        }
                    }},
                    {field : "SJHM",title : "手机号码",width:35,align:'center'},
                    {field : "JTZZ",title : "家庭住址",width:70,align:'center',formatter:function(value){
                    	return formatTitle(value);
					}},
                    {field : "QYSJ",title : "预签约时间",width:28,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "RQFLMC",title : "人群分类",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "TDMC",title : "签约团队",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "FWBMC",title : "签约服务包",width:40,align:'center',formatter:function(value){
                        return formatTitle(value);
                    }},
                    {field : "QYLX",title : "审核结果",width:25,align:'center',formatter:function(value){
                    	var qylxObj = {"06":"已拒绝", "07":"已接受"};
                    	return qylxObj[value] || value;
					}},
                    {field : "cz",title : "操作",width:40,align:'center', formatter:function(value,row,index){
                        row = JSON.stringify(row).replace(/"/g, '&quot;');
                        return '<span class="spanBtn" onclick="checkYqy(' + row + ')">详细</span>';
                    }}
                ]],
                pagination : true,
                url: contextRoot+"jtqy/queryPage.service",
                onBeforeLoad: function(params){
                    getContainerDataByClassName('yshConditionBox','condition',params);//查询条件
                    formatTdid(params,"YLTDID");
                    if(StringUtils.isEmpty(params.QYLX)) params.QYLX = "06,07";
                    if(StringUtils.isEmpty(params.YLTDID)) return false;
                }
            });
        }
	}
</script>
<body>
	<div id="tabs">
		<div title="未审核">
			<div class="easyui-layout" fit="true">
				<div region="north" style="background:#f9f9f9;overflow:hidden;border:0">
					<table class="form-table" id="wshConditionBox" style="margin:5px auto;">
						<tr>
							<td class="td-text">姓名：</td>
							<td class="td-content">
								<input name="XM" class="form-control condition" >
							</td>
							<td class="td-text">证件类型：</td>
							<td class="td-content">
								<select id="ZJLX" name="ZJLX" cacheTable="TB_ZY_ZJLX" placeholder="证件类型" class="form-control condition">
								</select>
							</td>
							<td class="td-text">证件号码：</td>
							<td class="td-content">
								<input name="ZJHM" class="form-control condition" >
							</td>
						</tr>
						<tr>
							<td class="td-text">预签约时间：</td>
							<td class="td-content">
								<!--预签约时间 == 签约时间-->
								<input name="QYSJ" class="form-control condition laydate-icon" onclick="laydate()">
							</td>
							<td class="td-text">预签约团队：</td>
							<td class="td-content">
								<select name="YLTDID" class="form-control condition YLTDID" style="width: 90.7%">
									<option value="">请选择</option>
								</select>
							</td>
							<td class="td-text" style="width:80px;text-align:center" colspan="2">
								<button class="btn btn-info btnCx" type="button" onclick="queryForm('wshYqyTb')">查询</button>
							</td>
						</tr>
					</table>
				</div>
				<div region="center" border="false">
					<table id="wshYqyTb"></table>
				</div>
			</div>
		</div>

		<div title="已审核">
			<div class="easyui-layout" fit="true">
				<div region="north" style="background:#f9f9f9;overflow:hidden;border:0">
					<table class="form-table" id="yshConditionBox" style="margin:5px auto;">
						<tr>
							<td class="td-text">姓名：</td>
							<td class="td-content">
								<input name="XM" class="form-control condition" >
							</td>
							<td class="td-text">证件号码：</td>
							<td class="td-content">
								<input name="ZJHM" class="form-control condition" >
							</td>
							<td class="td-text">预签约时间：</td>
							<td class="td-content">
								<!--预签约时间 == 签约时间-->
								<input name="QYSJ" class="form-control condition laydate-icon" onclick="laydate()">
							</td>
						</tr>
						<tr>
							<td class="td-text">预签约团队：</td>
							<td class="td-content">
								<select name="YLTDID" class="form-control condition YLTDID" style="width: 90.7%">
									<option value="">请选择</option>
								</select>
							</td>
							<td class="td-text">审核结果：</td>
							<td class="td-content">
								<select name="QYLX" class="form-control condition">
									<option value="">请选择</option>
									<option value="06">已拒绝</option>
									<option value="07">已接受</option>
								</select>
							</td>
							<td class="td-text" style="width:80px;text-align:center" colspan="2">
								<button class="btn btn-info btnCx" type="button" onclick="queryForm('yshYqyTb')">查询</button>
							</td>
						</tr>
					</table>
				</div>
				<div region="center" border="false">
					<table id="yshYqyTb"></table>
				</div>
			</div>
		</div>
	</div>
</body>

</html>

